<template>
  <div class="app-container">
    <form-filter :lock-state="1" @on-filter="submitFilterForm"/>
    <el-table border :data="tableData.list" v-loading="loading" element-loading-text="加载中...">
      <el-table-column label="账户名" prop="username" align="center"></el-table-column>
      <!--<el-table-column label="账户类型" prop="userType" align="center">-->
      <!--<template slot-scope="{row}">-->
      <!--{{row.userType | toConverter('ACCOUNT_TYPE')}}-->
      <!--</template>-->
      <!--</el-table-column>-->
      <el-table-column label="锁定/解锁方式" align="center">
        <template slot-scope="{row}">
          {{row.optDesc}}
        </template>
      </el-table-column>
      <el-table-column label="锁定/解锁原因" prop="remark" align="center">
      </el-table-column>
      <el-table-column label="锁定/解锁时间" align="center">
        <template slot-scope="{row}">
          {{row.createTime | toTime}}
        </template>
      </el-table-column>
      <el-table-column label="申请人" prop="creator" align="center"></el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination background @size-change="gridSizeChange" @current-change="gridCurrentChange"
                     :current-page="filters.page" :page-sizes="gridPageSize" :page-size="filters.size"
                     :layout="gridLayout" :total="tableData.total">
      </el-pagination>
    </div>
  </div>

</template>

<script>

  import {getMemberLockLogs} from "@/services/api/member";
  import FormFilter from "./formFilter";
  import {grid} from '@/build'

  export default {
    name: "member-lock-logs",
    components: {FormFilter},
    mixins: [grid],
    data() {
      return {
        tableData: {},
        auditStep: 0,
        rowData: {},
        filters: {
          size: 20,
          page: 1,
          startDate: moment(moment().startOf('isoWeek')).format('YYYY-MM-DD 00:00:00'),
          endDate: moment().format('YYYY-MM-DD 23:59:59'),
        },
        filterDateType: false
      }
    },
    methods: {
      submitFilterForm(formInline) {
        formInline = this.formatTime(formInline)
        this.filters = {...this.filters, ...formInline}
        this.gridSearch()
      },
      formatTime(form) {
        const {time} = form;
        let startDate = undefined, endDate = undefined;
        if (!_.isUndefined(time) && _.isArray(time)) {
          startDate = form.time[0];
          endDate = form.time[1];
          form = {...form, startDate, endDate}
        } else {
          this.filters.startDate = undefined;
          this.filters.endDate = undefined;
        }
        delete form.time;
        return form
      }

    },
    mounted() {
      this.bindGet(getMemberLockLogs, 'tableData', {
        action: 'getGrid',
        sendingData: 'filters'
      });
      this.getAll()

    }
  }
</script>

<style scoped>

</style>
